/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package web.compliance.mail.browser;

import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aya
 */
@XmlRootElement(name = "message")
public class Mail {
    
    private String from;
    private Date date;
    private String subject;
    private String content;
    private String content_overview;
    private String name;
    private String msg_id;
    private String reply_to;
    private boolean attachement; 

    public Mail() {
        from = "";
        subject = "";
        content = "";
        content_overview = "";
        name = "";
        msg_id = "";
        reply_to = "";
    }

    @XmlElement
    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    @XmlElement
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
    @XmlElement
    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    @XmlElement
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
        if(content.length() > 50)
            this.content_overview = content.substring(0, 50)+"...";
        else
            this.content_overview = content;
    }

    @XmlElement
    public String getContent_overview() {
        return content_overview;
    }
    

    public void setName(String name) {
        this.name = name;
    }
    
    @XmlElement
    public String getName() {
        return name;
    }
    
    @XmlElement
    public String getMsgId() {
        return msg_id;
    }
    
    public void setMsgId(String msgid) {
        this.msg_id = msgid;
    }


    public void setAttachement(boolean status) {
        this.attachement = status;
    }    
    
    @XmlElement
    public boolean getAttachement() {
        return attachement;
    }    
    
    @XmlElement
    public String getReplyTo() {
        return reply_to;
    }
    
    public void setReplyTo(String reply_to) {
        this.reply_to = reply_to;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (this.from != null ? this.from.hashCode() : 0);
        hash = 83 * hash + (this.date != null ? this.date.hashCode() : 0);
        hash = 83 * hash + (this.subject != null ? this.subject.hashCode() : 0);
        hash = 83 * hash + (this.content != null ? this.content.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Mail other = (Mail) obj;
        if ((this.from == null) ? (other.from != null) : !this.from.equals(other.from)) {
            return false;
        }
        if (this.date != other.date && (this.date == null || !this.date.equals(other.date))) {
            return false;
        }
        if ((this.subject == null) ? (other.subject != null) : !this.subject.equals(other.subject)) {
            return false;
        }
        if ((this.content == null) ? (other.content != null) : !this.content.equals(other.content)) {
            return false;
        }
        return true;
    }
    
}
